/*
	File:		Entity.h
	Course:		SGD 1301
	Author:		dmonroe
	Purpose:	CEntity class is the concrete base class for
				moving entities
*/

#pragma once

#include "IEntity.h"


////////////////////////////////////////////////////////////
// CEntity class
//	- concrete base class for game entities
//	- implements the IEntity interface
//	- velocity based movement
class CEntity : public IEntity
{
public:
	////////////////////////////////////////////////////////
	CEntity( void );
	virtual ~CEntity( void );
	
	////////////////////////////////////////////////////////
	// IEntity Interface:
	virtual void Update( float fElapsedTime );
	virtual void Render( void );
	virtual int  GetType( void ) const				{	return m_eType;		}
	virtual RECT GetRect( void ) const;
	virtual bool CheckCollision( IEntity* pOther );

	virtual void AddRef( void );
	virtual void Release( void );

	
	////////////////////////////////////////////////////////
	// Accessors:
	float	GetPosX		( void ) const	{	return m_fPosX;		}
	float	GetPosY		( void ) const	{	return m_fPosY;		}
	float	GetVelX		( void ) const	{	return m_fVelX;		}
	float	GetVelY		( void ) const	{	return m_fVelY;		}
	int		GetWidth	( void ) const	{	return m_nWidth;	}
	int		GetHeight	( void ) const	{	return m_nHeight;	}	
	int		GetImageID	( void ) const	{	return m_nImageID;	}
	float	GetSpeed		( void ) const	{	return m_fSpeed			;		}
	float	GetRotation		( void ) const	{	return m_fRotation		;		}
	CEntity*	GetTarget		( void ) const	{	return m_pTarget		;		}

	// Mutators:	
	void	SetPosX		( float x	)	{	m_fPosX		= x;	}
	void	SetPosY		( float y	)	{	m_fPosY		= y;	}
	void	SetVelX		( float vx	)	{	m_fVelX		= vx;	}
	void	SetVelY		( float vy	)	{	m_fVelY		= vy;	}
	void	SetWidth	( int w		)	{	m_nWidth	= w;	}
	void	SetHeight	( int h		)	{	m_nHeight	= h;	}	
	void	SetImageID	( int id	)	{	m_nImageID	= id;	}
	void	SetSpeed		( float speed		)	{	m_fSpeed		= speed;		}
	void	SetRotation		( float rotation	)	{	m_fRotation		= rotation;		}
	void	SetTarget		( CEntity* Target	);

public:
	////////////////////////////////////////////////
	// type
	enum	EntityType	{ ENT_BASE, ENT_SHIP, ENT_LASER, ENT_TURRET	,ENT_AISHIP,ENT_INPUTSHIP, ENT_TILES,ENT_POWERUP1,ENT_POWERUP2,ENT_POWERUP3,ENT_POWERUP4,};

	EntityType			m_eType;

protected:
	
	void	rotate_point(float cx, float cy, float angle, POINT& p);
	////////////////////////////////////////////////////////
	// position
	float	m_fPosX;
	float	m_fPosY;

	// velocity
	float	m_fVelX;
	float	m_fVelY;

	// size
	int		m_nWidth;
	int		m_nHeight;

	// image
	int		m_nImageID;
	
	//others
	float	m_fSpeed		;
	float	m_fRotation		;

	//Target
	CEntity*	m_pTarget		;

	// reference count
	unsigned int	m_unRefCount;
};

